{
  description = "Kai's Home Manager & NixOS configurations";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    nix-flatpak.url = "github:gmodena/nix-flatpak";
    preservation.url = "github:nix-community/preservation";
    lanzaboote.url = "github:nix-community/lanzaboote";
    helix.url = "github:helix-editor/helix";
    yazi.url = "github:sxyazi/yazi";
    niri.url = "github:sodiboo/niri-flake";
    noctalia = {
      url = "github:noctalia-dev/noctalia-shell";
      inputs.nixpkgs.follows = "nixpkgs";
    };
    nvidia-patch = {
      url = "github:icewind1991/nvidia-patch-nixos";
      inputs.nixpkgs.follows = "nixpkgs";
    };
    betterfox = {
      url = "github:HeitorAugustoLN/betterfox-nix";
      inputs.nixpkgs.follows = "nixpkgs";
    };
    haumea = {
      url = "github:nix-community/haumea/v0.2.2";
      inputs.nixpkgs.follows = "nixpkgs";
    };
    home-manager = {
      url = "github:nix-community/home-manager";
      inputs.nixpkgs.follows = "nixpkgs";
    };
    nix-index-database = {
      url = "github:Mic92/nix-index-database";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs =
    inputs:
    with inputs;
    let
      userName = "kai";
      hostName = "z3-air";
    in
    {
      nixosConfigurations.${hostName} = nixpkgs.lib.nixosSystem rec {
        specialArgs = removeAttrs inputs [ "self" ] // {
          inherit userName hostName;
        };
        modules = [
          home-manager.nixosModules.default
          preservation.nixosModules.default
          lanzaboote.nixosModules.lanzaboote
          nix-index-database.nixosModules.nix-index

          ./hardware-configuration.nix
          (
            { pkgs, ... }@args:
            with haumea.lib;
            load {
              src = ./src;
              loader = loaders.scoped;
              inputs = args;
              transformer = transformers.liftDefault;
            }
          )

          {
            home-manager = {
              useGlobalPkgs = true;
              useUserPackages = true;
              extraSpecialArgs = specialArgs;
              users.${userName}.imports = [
                noctalia.homeModules.default
                betterfox.homeModules.betterfox
                nix-flatpak.homeManagerModules.nix-flatpak

                (
                  { pkgs, ... }@args:
                  with haumea.lib;
                  load {
                    src = ./home;
                    loader = loaders.scoped;
                    inputs = args;
                    transformer = transformers.liftDefault;
                  }
                )
              ];
            };
          }
        ];
      };
    };
}
